package cn.iocoder.yudao.module.dr.dal.mysql.collectionmanagement;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.dr.controller.admin.collectionmanagement.vo.CollectionManagementPageReqVO;
import cn.iocoder.yudao.module.dr.dal.dataobject.collectionmanagement.CollectionManagementDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 藏品管理 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface CollectionManagementMapper extends BaseMapperX<CollectionManagementDO> {

    default PageResult<CollectionManagementDO> selectPage(CollectionManagementPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CollectionManagementDO>()
                .eqIfPresent(CollectionManagementDO::getGeneralAccessionNumber, reqVO.getGeneralAccessionNumber())
                .eqIfPresent(CollectionManagementDO::getNumberType, reqVO.getNumberType())
                .likeIfPresent(CollectionManagementDO::getName, reqVO.getName())
                .eqIfPresent(CollectionManagementDO::getNumber, reqVO.getNumber())
                .eqIfPresent(CollectionManagementDO::getNumberOfCases, reqVO.getNumberOfCases())
                .likeIfPresent(CollectionManagementDO::getOriginalName, reqVO.getOriginalName())
                .eqIfPresent(CollectionManagementDO::getEra, reqVO.getEra())
                .eqIfPresent(CollectionManagementDO::getNumberUnit, reqVO.getNumberUnit())
                .eqIfPresent(CollectionManagementDO::getGeologicalEra, reqVO.getGeologicalEra())
                .eqIfPresent(CollectionManagementDO::getActualQuantity, reqVO.getActualQuantity())
                .eqIfPresent(CollectionManagementDO::getArchaeologicalEra, reqVO.getArchaeologicalEra())
                .eqIfPresent(CollectionManagementDO::getSizeLength, reqVO.getSizeLength())
                .eqIfPresent(CollectionManagementDO::getChineseHistoricalEra, reqVO.getChineseHistoricalEra())
                .eqIfPresent(CollectionManagementDO::getSizeWidth, reqVO.getSizeWidth())
                .eqIfPresent(CollectionManagementDO::getSizeHeight, reqVO.getSizeHeight())
                .eqIfPresent(CollectionManagementDO::getSpecificEra, reqVO.getSpecificEra())
                .eqIfPresent(CollectionManagementDO::getSpecificSize, reqVO.getSpecificSize())
                .eqIfPresent(CollectionManagementDO::getCategory, reqVO.getCategory())
                .eqIfPresent(CollectionManagementDO::getWeightRange, reqVO.getWeightRange())
                .eqIfPresent(CollectionManagementDO::getMaterialCategory1, reqVO.getMaterialCategory1())
                .eqIfPresent(CollectionManagementDO::getMaterialCategory2, reqVO.getMaterialCategory2())
                .eqIfPresent(CollectionManagementDO::getSpecificWeight, reqVO.getSpecificWeight())
                .eqIfPresent(CollectionManagementDO::getWeightUnit, reqVO.getWeightUnit())
                .eqIfPresent(CollectionManagementDO::getMaterial, reqVO.getMaterial())
                .eqIfPresent(CollectionManagementDO::getRelicLevel, reqVO.getRelicLevel())
                .eqIfPresent(CollectionManagementDO::getRelicSource, reqVO.getRelicSource())
                .eqIfPresent(CollectionManagementDO::getCompletenessDegree, reqVO.getCompletenessDegree())
                .eqIfPresent(CollectionManagementDO::getCompletenessCondition, reqVO.getCompletenessCondition())
                .eqIfPresent(CollectionManagementDO::getPreservationState, reqVO.getPreservationState())
                .eqIfPresent(CollectionManagementDO::getCollectionTimeRange, reqVO.getCollectionTimeRange())
                .eqIfPresent(CollectionManagementDO::getCollectionYear, reqVO.getCollectionYear())
                .eqIfPresent(CollectionManagementDO::getCollectionRegistrationNumber, reqVO.getCollectionRegistrationNumber())
                .eqIfPresent(CollectionManagementDO::getVersion, reqVO.getVersion())
                .eqIfPresent(CollectionManagementDO::getStorageVolume, reqVO.getStorageVolume())
                .eqIfPresent(CollectionManagementDO::getAdministrativeDivision, reqVO.getAdministrativeDivision())
                .eqIfPresent(CollectionManagementDO::getUnitCode, reqVO.getUnitCode())
                .likeIfPresent(CollectionManagementDO::getUnitName, reqVO.getUnitName())
                .betweenIfPresent(CollectionManagementDO::getCreateTime, reqVO.getCreateTime())
                .last("ORDER BY CONVERT(INTEGER, GENERAL_ACCESSION_NUMBER) ASC"));  // 达梦的 CONVERT 语法
    }

    public CollectionManagementDO selectByGeneralAccessionNumber(String generalAccessionNumber);

}